{-# LANGUAGE TemplateHaskell #-}

module Vote.Internal.Table where
  
import Vote.TH.Opaleye
import Protolude
import Opaleye
import Data.Time
import Data.Profunctor.Product

data Scene
  = Scene
      (PropD "id" Int64 (Maybe (Field SqlInt8)) (Field SqlInt8))
      (PropS "type" Text (Field SqlText))
      (PropS "info" Text (Field SqlText))
      (PropD "time_open" (Maybe UTCTime) (FieldNullable SqlTimestamptz) (FieldNullable SqlTimestamptz))
      (PropD "time_shut" (Maybe UTCTime) (FieldNullable SqlTimestamptz) (FieldNullable SqlTimestamptz))
      (PropS "mark_deno" Int (Field SqlInt4))

makeTable "scene" ''Scene

data Actor
  = Actor
      (PropD "id" Int64 (Maybe (Field SqlInt8)) (Field SqlInt8))
      (PropS "info" Text (Field SqlText))

makeTable "actor" ''Actor

data Voter
  = Voter
      (PropD "id" Int64 (Maybe (Field SqlInt8)) (Field SqlInt8))
      (PropS "info" Text (Field SqlText))
      (PropS "factor_nume" Int (Field SqlInt4))
      (PropS "factor_deno" Int (Field SqlInt4))

makeTable "voter" ''Voter

data Action
  = Action
      (PropD "id" Int64 (Maybe (Field SqlInt8)) (Field SqlInt8))
      (PropS "scene_id" Int64 (Field SqlInt8))
      (PropS "actor_id" Int64 (Field SqlInt8))
      (PropS "voter_id" Int64 (Field SqlInt8))
      (PropS "mark_nume" Int (Field SqlInt4))

makeTable "action" ''Action